<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员登录</title>
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f4f7fa;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
        }
        .login-container {
            background-color: #ffffff;
            border-radius: 10px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
            padding: 40px;
            transition: all 0.3s ease;
        }
        .login-container:hover {
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
        }
        .login-header {
            text-align: center;
            margin-bottom: 30px;
        }
        .login-header h2 {
            color: #333;
            margin: 0;
            font-size: 28px;
            font-weight: 600;
        }
        .login-header p {
            color: #666;
            margin: 10px 0 0;
        }
        .form-group {
            margin-bottom: 20px;
            position: relative;
        }
        .form-group label {
            display: block;
            margin-bottom: 8px;
            color: #555;
            font-size: 14px;
            font-weight: 500;
        }
        .form-control {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 14px;
            color: #333;
            transition: border-color 0.3s ease;
        }
        .form-control:focus {
            outline: none;
            border-color: #2196F3;
            box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
        }
        .btn-login {
            width: 100%;
            padding: 12px 0;
            background-color: #2196F3;
            border: none;
            border-radius: 6px;
            color: white;
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }
        .btn-login:hover {
            background-color: #0b7dda;
        }
        .btn-login:active {
            background-color: #0a69b8;
        }
        .error-message {
            color: #e74c3c;
            font-size: 14px;
            margin-top: 10px;
            text-align: center;
            display: none;
        }
        .success-message {
            color: #2ecc71;
            font-size: 14px;
            margin-top: 10px;
            text-align: center;
            display: none;
        }
        .icon {
            position: absolute;
            right: 15px;
            top: 38px;
            color: #aaa;
        }
        .toggle-password {
            cursor: pointer;
        }
        .footer {
            text-align: center;
            margin-top: 20px;
            color: #888;
            font-size: 13px;
        }
        .footer a {
            color: #2196F3;
            text-decoration: none;
        }
        .footer a:hover {
            text-decoration: underline;
        }
        .animated {
            animation-duration: 0.5s;
            animation-fill-mode: both;
        }
        @keyframes shake {
            0%, 100% {transform: translateX(0);}
            10%, 30%, 50%, 70%, 90% {transform: translateX(-5px);}
            20%, 40%, 60%, 80% {transform: translateX(5px);}
        }
        .shake {
            animation-name: shake;
        }
    </style>
    <script>
        function validateForm() {
            var username = document.getElementById("username").value;
            var password = document.getElementById("password").value;
            var errorMessage = document.getElementById("error-message");

            errorMessage.style.display = "none";

            if (username === "") {
                showError("请输入用户名");
                return false;
            }

            if (password === "") {
                showError("请输入密码");
                return false;
            }

            // 表单验证通过，显示加载状态
            document.getElementById("btn-login").innerHTML = "登录中...";
            document.getElementById("btn-login").disabled = true;

            // 模拟AJAX提交
            setTimeout(function() {
                document.getElementById("loginForm").submit();
            }, 1000);

            return true;
        }

        function showError(message) {
            var errorMessage = document.getElementById("error-message");
            errorMessage.textContent = message;
            errorMessage.style.display = "block";
            document.querySelector(".login-container").classList.add("shake");

            setTimeout(function() {
                document.querySelector(".login-container").classList.remove("shake");
            }, 500);

            // 重置按钮状态
            document.getElementById("btn-login").innerHTML = "登录";
            document.getElementById("btn-login").disabled = false;
        }

        function togglePasswordVisibility() {
            var passwordField = document.getElementById("password");
            var icon = document.querySelector(".toggle-password i");

            if (passwordField.type === "password") {
                passwordField.type = "text";
                icon.classList.remove("fa-eye");
                icon.classList.add("fa-eye-slit");
            } else {
                passwordField.type = "password";
                icon.classList.remove("fa-eye-slit");
                icon.classList.add("fa-eye");
            }
        }
    </script>
</head>
<body>
<div class="login-container animated">
    <div class="login-header">
        <h2>管理员登录</h2>
        <p>请输入您的账户信息</p>
    </div>

    <form id="loginForm" action="loginProcess" method="post" onsubmit="return validateForm();">
        <div class="form-group">
            <label for="username">用户名</label>
            <input type="text" id="username" name="username" class="form-control" placeholder="请输入用户名">
            <div class="icon">
                <i class="fa fa-user"></i>
            </div>
        </div>

        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" id="password" name="password" class="form-control" placeholder="请输入密码">
            <div class="icon toggle-password" onclick="togglePasswordVisibility()">
                <i class="fa fa-eye"></i>
            </div>
        </div>

        <button type="submit" id="btn-login" class="btn-login">登录</button>

        <div id="error-message" class="error-message"></div>
        <div id="success-message" class="success-message"></div>
    </form>

    <div class="footer">
        <p>© 2025在线考试系统 | <a href="#">忘记密码?</a></p>
    </div>
</div>
</body>
</html>